﻿<%@ WebHandler Language="C#" Class="saveidCard" %>

using System;
using System.Web;
using System.IO;

/// <summary>
/// 保存身份证
/// </summary>

public class saveidCard : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        //-1表示失败，1表示成功
        string state = "-1";
        string picurl = "";
        string base64 = "";

        try
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset = "utf-8";

            string strDay = System.DateTime.Now.ToString("yyyyMM");
            string uploadPath = HttpContext.Current.Server.MapPath("~/upload/" + strDay);
            if (!System.IO.Directory.Exists(uploadPath))
            {
                System.IO.Directory.CreateDirectory(uploadPath);
            }

            string id = context.Request["id"];
            string ext = context.Request["ext"];
            base64 = context.Request["formFile"];
            string sql = "update deliverInformation set  revevar2='" + base64 + "' where deliverid=" + id;
            WebUtility.excutesql(sql);
            state = "1";
        }
        catch (Exception ee)
        {
            Hangjing.AppLog.AppLog.Error("上传图片失败：" + ee);
        }
        finally
        {
            context.Response.Clear();
            context.Response.Write("{\"pic\":\"" + picurl + "\",\"state\":\"" + state  + "\"}");
            context.Response.End();
        }


    }


    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}